package cn.yunhe.services;

import cn.yunhe.dao.IFoodDaoMapper;
import cn.yunhe.entity.merchantsentity.Food;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.Map;
/**
 * 周依博
 */
public class AddFoodService {
    SqlSession session = null;
    IFoodDaoMapper foodDaoMapper = null;
    public int addFood(Food food){
        int result;
        try{
            session = SqlSessionFactoryUtil.getSqlSession();
            foodDaoMapper = session.getMapper(IFoodDaoMapper.class);
            result=foodDaoMapper.addFood(food);
            session.commit();
        }finally {
            session.close();
        }

        return result;
    }
    public int searchFood(Map map){
        int result;
        try {
            session = SqlSessionFactoryUtil.getSqlSession();
            foodDaoMapper = session.getMapper(IFoodDaoMapper.class);
            result= foodDaoMapper.searchFood(map);
        }finally {
            session.close();
        }

        return result;
    }
}
